package com.yeskery.nut.extend.mcp.server.method;

import com.yeskery.nut.bean.ApplicationContext;
import com.yeskery.nut.extend.mcp.core.Prompt;
import com.yeskery.nut.extend.mcp.core.schema.PromptSchema;
import com.yeskery.nut.extend.mcp.server.McpServerCapability;

import java.util.stream.Collectors;

/**
 * 提示列表方法处理器
 * @author sprout
 * 2025-04-17 15:20
 */
public class PromptsListMethodHandler extends BaseListMethodHandler {
    /**
     * 构造工具列表方法处理器
     * @param applicationContext  应用上下文
     * @param mcpServerCapability 服务能力
     */
    public PromptsListMethodHandler(ApplicationContext applicationContext, McpServerCapability mcpServerCapability) {
        super(applicationContext, mcpServerCapability);
    }

    @Override
    protected Object getHandleResult(String cursor) {
        McpServerCapability mcpServerCapability = getMcpServerCapability();
        PromptSchema.ListPromptsResult result = new PromptSchema.ListPromptsResult();
        result.setPrompts(mcpServerCapability.getPrompts().stream().skip(parseNumberCursor(cursor)).map(Prompt::getPrompt).collect(Collectors.toList()));
        return result;
    }
}
